import random

words = ["program", "banana", "computer", "orange", "since", "music", "application", "reference"]


def makeCiphertext(word, stated):
    ct = ""
    for i in range(len(stated)):
        if not stated[i]:
            ct += "*"
        else:
            ct += word[i]
    return ct


def guessOver(stated):
    for s in stated:
        if s == False:
            return False
    return True


def changeStated(ch, word, stated):
    for i in range(len(word)):
        if ch == word[i]:
            if (stated[i]):
                return False
            stated[i] = True
    return True


while True:
    word = words[random.randint(0, len(words) - 1)]
    stated = [False] * len(word)
    missedTime = 0
    while not guessOver(stated):
        ciphertext = makeCiphertext(word, stated)
        print("Enter a letter in word " + ciphertext + " >", end="")
        ch = input()
        if word.__contains__(ch):
            if not changeStated(ch, word, stated):
                print(ch + " is already in the word")
        else:
            missedTime += 1
            print(ch + " is not in the word")
    print("The word is " + word + " You missd " + str(missedTime) + " time.")
    print("Do you want to guess nother word? Enter y or n >", end="")
    choice = input()
    if choice == "n":
        break
